package com.pactera.integral.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.pactera.integral.common.repository.GenericRepository;
import com.pactera.integral.entity.UserAdditionalScore;

@Repository("userAdditionalScoreDao")
public interface UserAdditionalScoreDao extends GenericRepository<UserAdditionalScore, String> {

	UserAdditionalScore findById(String id);

	@Query(value = "select sum(iuas.audit_score) as score from INT_USER_ADDITIONAL_SCORE iuas where iuas.user_id = :userId and iuas.year = :year and iuas.month = :month and iuas.status = 3", nativeQuery = true)
	Integer findByDetail(@Param("userId") String userId, @Param("year") int year, @Param("month") int month);

	@Query(value = "select iuas.id from INT_USER_ADDITIONAL_SCORE iuas inner join sys_user su on su.DEPARTMENT_CODE like concat(:departmentCode,'%') where su.USER_ID = iuas.user_id and  iuas.status = 2", nativeQuery = true)
	List<String> findScoreIdByDepartmentCode(@Param("departmentCode") String departmentCode);
}
